package com.ruoyi.goods.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.goods.domain.WGoodsExtAssist;
import com.ruoyi.goods.service.IWGoodsExtAssistService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 建扩辅助Controller
 * 
 * @author ruoyi
 * @date 2024-05-27 21:48:33
 */
@RestController
@RequestMapping("/goods/extassist")
public class WGoodsExtAssistController extends BaseController
{
    @Autowired
    private IWGoodsExtAssistService wGoodsExtAssistService;

    /**
     * 查询建扩辅助列表
     */
    @PreAuthorize("@ss.hasPermi('goods:extassist:list')")
    @GetMapping("/list")
    public TableDataInfo list(WGoodsExtAssist wGoodsExtAssist)
    {
        startPage();
        List<WGoodsExtAssist> list = wGoodsExtAssistService.selectWGoodsExtAssistList(wGoodsExtAssist);
        return getDataTable(list);
    }

    /**
     * 导出建扩辅助列表
     */
    @PreAuthorize("@ss.hasPermi('goods:extassist:export')")
    @Log(title = "建扩辅助", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WGoodsExtAssist wGoodsExtAssist)
    {
        List<WGoodsExtAssist> list = wGoodsExtAssistService.selectWGoodsExtAssistList(wGoodsExtAssist);
        ExcelUtil<WGoodsExtAssist> util = new ExcelUtil<WGoodsExtAssist>(WGoodsExtAssist.class);
        util.exportExcel(response, list, "建扩辅助数据");
    }

    /**
     * 获取建扩辅助详细信息
     */
    @PreAuthorize("@ss.hasPermi('goods:extassist:query')")
    @GetMapping(value = "/{goodsExtAssistId}")
    public AjaxResult getInfo(@PathVariable("goodsExtAssistId") Long goodsExtAssistId)
    {
        return success(wGoodsExtAssistService.selectWGoodsExtAssistByGoodsExtAssistId(goodsExtAssistId));
    }

    /**
     * 新增建扩辅助
     */
    @PreAuthorize("@ss.hasPermi('goods:extassist:add')")
    @Log(title = "建扩辅助", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WGoodsExtAssist wGoodsExtAssist)
    {
        wGoodsExtAssist.setCreateBy(getNickName());
        return toAjax(wGoodsExtAssistService.insertWGoodsExtAssist(wGoodsExtAssist));
    }

    /**
     * 修改建扩辅助
     */
    @PreAuthorize("@ss.hasPermi('goods:extassist:edit')")
    @Log(title = "建扩辅助", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WGoodsExtAssist wGoodsExtAssist)
    {
        wGoodsExtAssist.setUpdateBy(getNickName());
        return toAjax(wGoodsExtAssistService.updateWGoodsExtAssist(wGoodsExtAssist));
    }

    /**
     * 删除建扩辅助
     */
    @PreAuthorize("@ss.hasPermi('goods:extassist:remove')")
    @Log(title = "建扩辅助", businessType = BusinessType.DELETE)
	@DeleteMapping("/{goodsExtAssistIds}")
    public AjaxResult remove(@PathVariable Long[] goodsExtAssistIds)
    {
        return toAjax(wGoodsExtAssistService.deleteWGoodsExtAssistByGoodsExtAssistIds(goodsExtAssistIds));
    }
}
